// LCA(Tarjan)
// https://soj.turingedu.cn/problem/60601/

int n;
vector<int> adj[maxn];
vector<int> qy[maxn];

int fa[maxn];
bool visit[maxn];

int find(int x) {
    if (fa[x] == x) return x;
    return fa[x] = find(fa[x]);
}

map<pair<int, int>, int> lca;
void dfs(int u, int p) {
    for (auto &v : adj[u]) {
        if (v == p)
            continue;
        dfs(v, u);
    }

    for (auto &v : qy[u]) {
        if (!visit[v]) continue;
        lca[{u, v}] = find(v);
    }

    visit[u] = 1;
    fa[u] = p;
}
